package com.rpc.example.loadbalance;

import com.rpc.example.ServiceInfo;
import org.apache.curator.x.discovery.ServiceInstance;

import java.util.List;
import java.util.Random;

/**
 *
 *
 * @author Elvis
 * @version 1.0, 2022/11/21
 */
public class RandomLoadBanlance extends AbstractLoadBanlance {
    @Override
    ServiceInstance<ServiceInfo> doSelect(List<ServiceInstance<ServiceInfo>> services) {
        int size = services.size();
        Random random = new Random();
        return services.get(random.nextInt(size));
    }
}
